﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.IO;

public partial class ChangePassword : WebPageBase
{

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            
        }
    }

    protected void ButtonChangePassword_Click(object sender, EventArgs e)
    {
        UserQ user = db.UserQs.Where(u => u.Id == UserSystem.Id && u.Password.Equals(TextBoxPassword.Text)).FirstOrDefault();

        if (user == null)
        {
            try
            {

                user.Password = TextBoxNewPassword.Text;
                db.SubmitChanges();

                Message1.Message = "Sus contraseña a sido modificada.";
                Message1.Type = Constant.MESSAGE_OK;
                
            }
            catch (Exception ex)
            {

            }
        }
        else
        {
            Message1.Message = "La contraseña actual es errónea.";
            Message1.Type = Constant.MESSAGE_ERROR;
        }
    }

}
